﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace eGrid_App
{
    /// <summary>
    /// A representation of a Bookmark as a "pin" to identify the location of
    /// the bookmark on a map.
    /// </summary>
    public class BookmarkPin
    {
        private Point scr_pt;
        private Bookmark bookmark;
        private bool toggle;
        private TextBlock descriptionBlock;


        #region Properties

        
        /// <summary>
        /// The description block of the BookmarkPin
        /// </summary>
        public TextBlock DescriptionBlock
        {
            get
            {
                return descriptionBlock;
            }
            set
            {
                this.descriptionBlock = value;
            }
        }

        /// <summary>
        /// The X cordinate of the pin on screen
        /// </summary>
        public int X
        {
            get
            {
                return (int) scr_pt.X;
            }
        }

        /// <summary>
        /// The Y cordinate of the pin on screen
        /// </summary>
        public int Y
        {
            get
            {
                return (int) scr_pt.Y;
            }
        }

        public Point ScreenPt
        {
            get
            {
                return scr_pt;
            }
            set
            {
                scr_pt = value;
            }
        }

        
        /// <summary>
        /// String description about the TroubleTicket
        /// </summary>
        public string Description
        {
            get
            {
                return bookmark.Description;
            }
        }

        public Bookmark.BookmarkPriority Priority
        {
            get
            {
                return bookmark.Priority;
            }
            set
            {
                bookmark.Priority = value;
            }
        }

        
        /// <summary>
        /// Gets the represented Bookmark of 
        /// this pin
        /// </summary>
        public Bookmark Bookmark
        {
            get
            {
                return bookmark;
            }
        }

        /// <summary>
        /// Gets if the BookmarkPin is active by
        /// being tapped
        /// </summary>
        public bool isActive
        {
            get
            {
                return toggle;
            }
        }

        #endregion
        

        #region Constructors
        /// <summary>
        /// Constructor for BookmarkPin.  Takes in the represented Bookmark and the screen point as arguments.
        /// </summary>
        /// <param name="troubleTicket"></param>
        /// <param name="screenPoint"></param>
        public BookmarkPin(Bookmark bm, Point screenPoint)
        {
            bookmark = bm;
            scr_pt = screenPoint;
            toggle = false;
            
            descriptionBlock = new TextBlock();
            descriptionBlock.Text = bm.Description;
            descriptionBlock.Height = 50;
            descriptionBlock.Width = 100;
            descriptionBlock.Background = new SolidColorBrush(Colors.White);
            descriptionBlock.Foreground = new SolidColorBrush(Colors.Black);
        }

        public BookmarkPin(Point screenPoint)
        {
            scr_pt = screenPoint;
        }

        #endregion

        /// <summary>
        /// This is called when the pin is tapped by a user.
        /// Keeps track if the description box is active.
        /// </summary>
        public void Tap()
        {
            if (toggle)
                toggle = false;
            else
                toggle = true;
        }

        /// <summary>
        /// Returns a TextBlock as the description block.
        /// </summary>
        /// <returns></returns>
        public TextBlock GetDescriptionBlock()
        {
            return descriptionBlock;
        }
    }
}
